package com.ybkj.daijia.server.websocket.command;

import java.util.HashMap;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

@Component
public class CommandFactory {

    private Map<String, Command> map = new HashMap<String, Command>();

    @Resource(name = "connectedCommand")
    private Command connectedCommand;

    public CommandFactory() {
        super();
    }

    @PostConstruct
    private void init() {

        Assert.notNull(connectedCommand);

        map.put("connected", connectedCommand);

    }

    public Command getCommand(String command) {

        return map.get(command);
    }

}
